package dealer.controls
{
	import dealer.Global;
	
	import flash.display.MovieClip;
	import flash.net.NetConnection;
	import flash.net.NetStream;

	public class InitVariables extends MovieClip
	{
		public function InitVariables()
		{
			super();
			init();
		}
		/* comment function */
		private function init():void
		{
			var _obj:Object=Global.STAGE.loaderInfo;
			if(_obj.parameters.roomno!=null){
				/* set variables */
				Global.VOD_RTMP=_obj.parameters.vodrtmp;
				Global.RTMP=_obj.parameters.rtmp;
				Global.VERSION_NO=_obj.parameters.versionno;
				Global.FORCE_RELOAD=_obj.parameters.forcereload;
				Global.WAIT_SEC=_obj.parameters.waitsec;
				Global.WAIT_SEC_START=_obj.parameters.waitsecstart;
				Global.ROOM_NO=_obj.parameters.roomno;
				Global.SESSION_ID=_obj.parameters.sessionid;
				Global.FMS_MONITOR=_obj.parameters.fmsmonitor;
				Global.GAME_TIME=_obj.parameters.gametime;
				Global.VDO_FMS=_obj.parameters.vdofms;
			}else{
				Global.VOD_RTMP="localhost/test";
				Global.RTMP="vod@live";
				Global.VERSION_NO="1.0";
				Global.FORCE_RELOAD="N";
				Global.WAIT_SEC=2;
				Global.WAIT_SEC_START=5;
				Global.ROOM_NO=5;
				Global.SESSION_ID="NA";
				Global.FMS_MONITOR="localhost/live";
				Global.GAME_TIME="10@20@30";
				Global.VDO_FMS="";								
			}
			/* set game time */
			setGameTime(Global.GAME_TIME);
			/* init bet code */
			initBetCode();
			/* trace variables */
			traceVariables();						
		}
		/* set game time function */
		private function setGameTime(gameTime:String):void
		{
			var gameTimeArray:Array=gameTime.split("@");			
			for(var i:int=0;i<gameTimeArray.length;i++){				
				Global["GAME_TIME"+(i+1)]=Number(gameTimeArray[i]);				
			}
			/* end for */
		}
		/* comment function */
		private function initBetCode():void
		{
			var outObjArray:Array=new Array();
			var rtmpArr:Array=Global.RTMP.split("@");
			for(var i:int=0;i<rtmpArr.length;i++){
				var initObject:Object=new Object();
				var nc:NetConnection=new NetConnection();
				var nc1:NetConnection=new NetConnection();
				//var vod:NetStream=new NetStream(nc);
				
				initObject={ncName:"rtmp"+i,ncRoom:nc1,ncRoomId:nc,sessionToken:null,res:null,vod:null};
				
				outObjArray.push(initObject);
			}
			/* end for */
			Global.BET_CODE_STRING=outObjArray;
		}
		/* comment function */
		private function traceVariables():void
		{
			var _str:String="VODRTMP:"+Global.VOD_RTMP+"\nRTMP:"+Global.RTMP+"\nVERSION:"+Global.VERSION_NO+"\nFORCE RELOAD:"+Global.FORCE_RELOAD+
				"\nWAI SEC:"+Global.WAIT_SEC+"\nWAIT SEC START:"+Global.WAIT_SEC_START+"\nROOM NO:"+Global.ROOM_NO+"\nSESSION:"+Global.SESSION_ID+"\nFMS MONITOR:"+Global.FMS_MONITOR
				+"\nGAME TIME:"+Global.GAME_TIME+"\nTIME1:"+Global.GAME_TIME1+"\nTIME2:"+Global.GAME_TIME2+"\nTIME3:"+Global.GAME_TIME3+"\nVDO FMS:"+Global.VDO_FMS+"\nCONNECT ROOMID:"+Global.BET_CODE_STRING;
			Global.TXT_FLASH_VAR.text=_str;
		}
	}
	/* End Class */
}